#!/bin/bash

DEBUG=0
EE_NO_SED_COMMAND=1

function debug {
	if [ $DEBUG == "1" ]
	then
		msg="$1"
		echo $msg;
	fi
}

#pre-requests
which sed > /dev/null 2>&1
if [ "$?" != "0" ]
then
	echo "generate_uva.c++: error: sed command not found. "
	exit $EE_NO_SED_COMMAND;
fi

srcdir="."
main=$srcdir/main.c++
foruva=$srcdir/uva.c++

utilsdir="utils"

#remove all comments, that's of no use to UVa.
$utilsdir/remccoms3.sed < $main | sed '/^\t*$/d' > $foruva

#print file size
filesize=`ls -sh "$foruva" | cut -d " " -f 1`
echo "File $foruva generated. File size: $filesize"
